import getApiData from "@/services/cpasRequest";


// 获取账套
export async function getAccountInfo(params: {
  dbname: string;
}) {
  if (!params.dbname) return [];
  const res = await getApiData("account.accountInfo.getDataList", params);
  if (res.ok) {
    return Promise.resolve({
      data: res.data,
      success: true,
    });
  }
  return Promise.resolve({
    data: [],
    success: false,
  });
}


// 获取账套
export async function getPresetTopSubject(params: {
  dbname: string;
  Data_ID: string,
  zcbfID: string
}) {
  if (!params.dbname) return [];
  const res = await getApiData("account.subject.getPresetTopSubjectList", params);
  if (res.ok) {
    return Promise.resolve({
      data: res.data,
      success: true,
    });
  }
  return Promise.resolve({
    data: [],
    success: false,
  });
}

// 增加科目
export async function Addsubject(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
  KMMC: string;
  editUser: string;
  PKMBH: string | any;
  YSKMBH: any;
  YSKMMC: string;
  KMFX: string;
  KMLX: string | any;
  JC: any;
  itemNames: string | any
}) {
  const res = await getApiData("account.subject.add", params);
  return res;
}


// 获取左侧切换的数据
export async function getSubjectType(params: {
  dbname: string;
  Data_ID: string
}) {
  const res = await getApiData("account.subject.getType", params);
  return Promise.resolve({
    data: res.data,
    success: res.ok,
  });
}